<template>
  <div>
    <Breadcrumb></Breadcrumb>
    <h1>修改套餐</h1>
    <el-form ref="form" :model="meal" label-width="80px">
      <el-form-item label="套餐名称">
        <el-input v-model="meal.name"></el-input>
      </el-form-item>
      <el-form-item label="时间">
        <el-input v-model="meal.mouth"></el-input>
      </el-form-item>

      <el-form-item label="原价">
        <el-input v-model="meal.normalPrice"></el-input>
      </el-form-item>

      <el-form-item label="打折价格">
        <el-input v-model="meal.salePrice"></el-input>
      </el-form-item>

      <el-form-item label="类型">
        <el-select v-model="meal.type" placeholder="是否推荐该套餐">
          <el-option label="推荐" value="1"></el-option>
          <el-option label="不推荐" value="0"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">确认修改</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
// 引入面包屑组件
import Breadcrumb from "@/commponents/common/Breadcrumb.vue";
export default {
  components: {
    Breadcrumb,
  },
  data() {
    return {
      meal: {
        _id: "",
        mouth: "",
        salePrice: "",
        normalPrice: "",
        type: "",
        name: "",
      },
    };
  },
  created() {
    this.meal._id = this.$route.params._id;
  },
  methods: {
    async onSubmit() {
      const { data } = await this.$api.Meal.mealUpData(this.meal);
      if (data.meta.status == 200) {
        this.$message({
          message: "修改成功",
          type: "success",
        });
        this.$router.push("/home/MealList");
      } else {
        this.$message.error("修改失败");
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.el-input {
  width: 500px;
}
</style>
